home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
301-325
/
disk_319
/
cnewssrc
/
cnews.orig.lzh
/
notebook
/
libs
< prev
next >
Wrap
Text File
|
1989-06-27
|
6KB
|
318 lines
.TL
A Tour Through the C News Libraries and Include Files
.AU
Geoff Collyer
.AI
Department of Statistics
University of Toronto
.SH
libc and friends
.LP
.I libc
contains routines that are sufficiently useful
and general that they could profitably be added to
one's C library.
Indeed,
on some systems they are in the C library.
Notable inventions include
.I fgetmfs
which safely reads arbitrarily-long input lines;
it has an
.B fgetmfs.h
over in the header directories.
.I ldiv
is the ANSI one,
if you need it.
.I memlist
is a
package to ease keeping track of a lot of allocated memory.
.I stdfdopen
is invoked by setuid programs
to ensure that the standard file descriptors are indeed open,
opening
.B /dev/null
on each closed standard descriptor.
.\".B libc/memcpy.fast
.\"contains some alternate
.\"implementations of
.\".I memcpy (3)
.\"which may be faster than the ones in your local C library.
.LP
.B libstdio
contains new (faster) guts for
the original
.UX
.I stdio
library;
if they compile on your V7,
4BSD
or System III
system,
you may want to use them instead of the default versions
in your C library.
On System V,
these routines are only slightly faster than the versions in the C library.
.LP
.B libfake
contains things that probably should be in your C library,
but might not be, and a couple of fake routines for system calls
you might not have.
.SH
libcnews
.LP
.B libcnews
contains functions of general use to news software,
but not the world at large.
.I complain
is like
.I warning ,
but never prints the symbolic value of
.I errno .
.PP
There is a locking package,
containing
.I lockdebug ,
.I newslock ,
.I newsunlock ,
.I errunlock ,
and
.I nemalloc .
.I lockdebug
enables or disables lock debugging.
.I newslock
attempts to lock
the news transport layer
against
read-then-write access to the
.B active
file,
writing to the
.B history *,
.B log ,
.B errlog ,
and batch files.
It returns only when it has the lock;
in the meantime it sleeps and retries until it gets the lock.
There is no timeout;
this is a feature.
.I newsunlock
removes the above-mentioned lock
if this process locked the news system.
.I errunlock
is like
.I error
except that it
unlocks the news system
(via
.I newsunlock)
before exiting;
it is should always be called instead of
.I exit (3)
or
.I exit (2)
if there is any chance that this process has locked the news system.
.I nemalloc
is like
.I emalloc
but it calls
.I errunlock
if it can't allocate memory.
.PP
.I ltoza
converts a
.B "long int"
to a string of a given width,
containing the decimal representation,
zero-padding as needed on the left.
.I ltozan
is like
.I ltoza
but omits the terminating NUL,
so it can be used to overwrite a string without truncating it.
.I ngmatch
returns a truth-value
resulting from comparing
a list of newsgroup patterns
and
a list of newsgroups.
One may substitute ``distribution'' for ``newsgroup''.
.PP
There is a package of pathname manipulators.
.I artfile
returns a name for its filename argument,
assumed to be relative to
.I $NEWSARTS ;
.I fullartfile
promises to return a fully-qualified path name.
.I ctlfile
returns a name for its filename argument,
assumed to be relative to
.I $NEWSCTL .
.I binfile
returns a name for its filename argument,
assumed to be relative to
.I $NEWSBIN .
.I cd
changes to its argument directory,
check for errors,
and notes the directory name,
by making a private copy,
for later optimisations.
.I newsumask
returns the value of
.I $NEWSUMASK .
.I newspath
returns the value of
.I $NEWSPATH .
.I newsmaster
returns the value of
.I $NEWSMASTER .
All these functions
supply default values for the
.I NEWS *
variables if none are found in the environment.
If values are found in the environment,
they are used,
and a function named
.I unprivileged
is called.
.PP
.I readline
is like
.I fgets ,
but executes
.I newslock
upon encountering EOF
and retries the read.
This is used when reading growing files
such as
.B history
or
batch files.
.I strlower
down-cases an entire string,
in place.
.I strsave
is like
.I strdup
but it calls
.I nemalloc
rather than
.I emalloc .
.I str3save
takes three strings,
allocates space for their concatenation
via
.I nemalloc ,
including terminating NUL,
and concatenates them onto it.
A
.I NULL
argument will be replaced by an empty string.
.I timestamp
writes a timestamp on a given stream,
and returns the current time via an argument
for later use.
.SH
Unix-variant-specific libraries
.LP
There are several libraries that provide functions
for talking to specific Unix variants.
These are basically functions that change from one variant to another.
.B libfake
(see above) contains things which simply might not be there in a
particular system.
.LP
These libraries all provide the same virtual interface to
operating-system-dependent services:
.I fclsexec ,
.I fopenexcl ,
.I getcwd (3),
and
.I gethostname (3).
Implementations for vanilla implementations of these
.UX
variants are provided:
Seventh Edition,
including 4.1BSD
(\c
.B libv7 );
Eighth
and Ninth Editions
(\c
.B libv8 );
4.2BSD and later
(\c
.B libbsd42 );
System III and System V
(\c
.B libusg ).
.I fclsexec
sets the close-on-exec flag
for a given
.I stdio
stream.
.I fopenexcl
performs an ``exclusive create'' open:
the open fails if the file already exists.
.SH
Address-space-size-specific libraries
.LP
These libraries provide alternate versions of the
.B active
and
.B sys
file code:
.B libsmall
should work on any machine,
but is suboptimally fast;
.B libbig
has worked even on PDP-11s,
and is quite fast,
but consumes memory without apology.
.SH
Include files
.LP
.B libh
contains include files
unique to C news.
.B news.h
defines a few limits,
some file names,
some types
(\c
.B boolean
and
.B statust ),
some characters,
some status bits,
some macros for speed,
and
declares functions in
.B libcnews
or miscellaneous functions in
.I relaynews
(oops!).
.B config.h
declares the pathname functions in
.B libcnews .
.B fgetmfs.h
declares symbolic values and macros for using
.B fgetmfs .
.B libc.h
is a start at a V9-like declaration of all of the C library.
.B memlist.h
defines the interface to
.B memlist .
.LP
.B hfake
contains a few include files that your system ought to have but might not.
.B stdlib.h
is a degenerate ANSI
.B stdlib.h .
.B string.h
declares the string functions.
.B timeb.h
declares the structure used by
.I ftime .